package demo7;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Person {
    private String name;
    public Person() {
        System.out.println("1.这是person的构造器");
    }

    public String getName() {
        return name;
    }
    @Value("六六")
    public void setName(String name) {
        System.out.println("2.person的setname方法被调用了");
        this.name = name;
    }
    public void play(){
        System.out.println("person的play()方法被调用了");
    }
    @PostConstruct
    public  void init(){
        System.out.println("3.person初始化完毕");
    }
    @PreDestroy
    public void preDestroy(){
        System.out.println("容器即将销毁");
    }
}
